package com.mars.module.app.controller;


import com.mars.common.enums.BusinessType;
import com.mars.common.response.PageInfo;
import com.mars.common.result.R;
import com.mars.common.util.ExcelUtils;
import com.mars.framework.annotation.Log;
import com.mars.framework.annotation.RateLimiter;
import com.mars.module.admin.entity.ApCookbook;
import com.mars.module.admin.request.ApCookbookRequest;
import com.mars.module.admin.response.ApCookbookResponse;
import com.mars.module.admin.service.IApCookbookService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

/**
 * 菜谱控制层
 *
 * @author mars
 * @date 2024-02-24
 */
@Slf4j
@AllArgsConstructor
@RestController
@Api(value = "菜谱接口管理", tags = "菜谱接口管理")
@RequestMapping("/app/apCookbook")
public class AppCookbookController {

    private final IApCookbookService iApCookbookService;

    /**
     * 分页查询菜谱列表
     */
    @ApiOperation(value = "分页查询菜谱列表")
    @PostMapping("/pageList")
    public R<PageInfo<ApCookbook>> pageList(@RequestBody ApCookbookRequest apCookbookRequest) {
        return R.success(iApCookbookService.pageList(apCookbookRequest));
    }

    /**
     * 获取菜谱详细信息
     */
    @ApiOperation(value = "获取菜谱详细信息")
    @GetMapping(value = "/query")
    public R<ApCookbookResponse> detail(String id) {
        return R.success(iApCookbookService.appDetail(id));
    }


    /**
     * 查询菜谱列表
     *
     * @param apCookbookRequest apCookbookRequest
     * @return R
     */
    @ApiOperation(value = "查询菜谱列表")
    @PostMapping("/list")
    public R<List<ApCookbook>> list(@RequestBody ApCookbookRequest apCookbookRequest) {
        return R.success(iApCookbookService.list(apCookbookRequest));
    }


}
